Problem description?? When we use the Spring Framework for project development, the Autosire mechanism in spring is often used in order to configure the bean, and autowire can be divided into ==byname== and ==bytype== depending on the injection
Let's sort out the automatic assembly autowire section of spring today. Here we want to solve the following problems:1. What is automatic assembly?2 What is the significance of automatic assembly?§ 3 what types of automatic assembly are available?§ 4
Annotations such as @Autowired and @resource inject beans from the spring container into properties, while annotations such as @component are managed in the spring container.@Autowiredspring2.1 allows the user to annotate the bean's attribute
Dependency injection (ioc di)
Two Methods of dependency injection:
1. set Injection
When Spring requires the set injection method, Bean needs to provide a construction method without parameters. And provides a property setter method. For example:
1. Using spring annotations to inject properties
1.1. How we injected attributes before using annotationsimplementation of the class:
Class Usermanagerimpl implements Usermanager {
private Userdao Userdao;
public void Setuserdao
First, the automatic assembly modelThe following is the automatic connection mode, which can be used to instruct the spring container to use automatic connection for dependency injection. You can use the Autowire property of an element to specify
The official definition of automatic assembly is as follows:The Spring IoC container can automatically assemble (autowire) the association between beans that collaborate with each other. Therefore, if possible
Let spring specify the bean
The notes are not updated because they have been busy for the past few days.
Spring. Net has the ability to automatically assemble, that is, spring. Net can automatically distinguish the collaborative objects of an object through the definition of
The spring container can automatically assemble the relationships between the mutual collaboration beans, which helps reduce the configuration of the XML without having to write a large number of and elements based on the spring application.
Spring Kernel Research-managing bean Declaration cycles One (Initializingbean and Init-method)
Initializingbean
SPIRNG's Initializingbean provides a way for the bean to define the initialization method. Initializingbean is an interface that
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.